Skip to content

Conversation

@MrDwarf7
Copy link

Summary

Closes: #366

Attempt to expand XDG_DATA_HOME when creating constants, falling back to ~/.local/share if not set.
Change also allows users to set application specific env. variables if they wiish to do so.

Testing

Seemingly no python req's file so entirely blind on versions.
There's also no actual testing tooling I could see in the entire repo - not without nuking my local copy too.

@mtwebster
Copy link
Member

This is super overkill I think -

  • I don't think checking an environment variable is useful - there's no reason for that to change. If the user wants to have a different location to save a profile in they can edit the launcher file that gets generated.
  • You should just use GLib.get_user_data_dir() which will return the expanded path to ~/.local/share. If someone really wants to override this they can set XDG_DATA_HOME to override the default at runtime.

@MrDwarf7
Copy link
Author

@mtwebster - Thanks for reviewing the PR and for the suggestion to use GLib.get_user_data_dir(). I agree that it's a clean way to respect XDG_DATA_HOME out of the box, and it would address the core issue of the hardcoded paths ignoring environment variables.

The current implementation does indeed ignore XDG_DATA_HOME, which is why the app creates directories like ~/.local/share/ice even when a custom setup is in place. Leading to unwanted directories outside the user's intended structure. This is the exact problem I encountered and aimed to fix with this PR (as described in #366).

To illustrate, here's an example from my own environment where I use non-standard paths, but still designed to conform to the XDG SPEC to control the creation and clutter of various XDG spec dirs or similar:

# Using prefix: 'XDG_'
# Environment variables starting with 'XDG_':
XDG_BIN_HOME = /home/dwarf/.xdg/bin
XDG_CACHE_HOME = /home/dwarf/.xdg/cache
XDG_CACHE_LOCAL_HOME = /home/dwarf/.xdg/local
XDG_CONFIG_HOME = /home/dwarf/.config
XDG_DATA_HOME = /home/dwarf/.xdg/data
XDG_STATE_HOME = /home/dwarf/.xdg/state

In this setup, the app should ideally use something like $XDG_DATA_HOME/ice (or equivalent) to conform to the XDG Base Directory Specification.
The PR not only enables this but also adds optional app-specific overrides (e.g., WEBAPP_MANAGER_ICE_DIR) for users who want fine-grained control without altering global variables that affect other apps.

I think combining your GLib suggestion with the custom env var support could strike a good balance—simpler core logic while keeping the extra flexibility.
I'd be happy to update the PR accordingly to use GLib as the foundation and ensure no extraneous subdirectories (like an extra /share) are added when XDG_DATA_HOME is set.

What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Application doesn't conform to XDG specs

2 participants